package thread_pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/19
 * Time:21:34
 * OOM异常
 **/
public class PoolDemo10 {
    public static void main(String[] args) {
        Object[] objects = new Object[15];
        ExecutorService service = Executors.newFixedThreadPool(15);
        for (int i = 0; i < 15; i++) {
            int finalI = i;
            service.execute(new Runnable() {
                @Override
                public void run() {
                    System.out.println("执行："+finalI);
                    MyOOMClass myOOMClass = new MyOOMClass();
                    objects[finalI] = myOOMClass;
                }
            });
        }
    }
    static class MyOOMClass{
        //创建一个大对象1M(M->KB->B)
        private byte[] bytes = new byte[1*1024*1024];

    }
}
